x86/vmx: use a MEMF_no_refcount domheap page for APIC_DEFAULT_PHYS_BASE
authorPaul Durrant <pdurrant@amazon.com>
Fri, 24 Jan 2020 14:49:35 +0000 (14:49 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 14 Feb 2020 14:24:50 +0000 (14:24 +0000)
commitea3daabff5f2be6f5dd5c3f4d6890746c4ec5378
tree67226248b86e2c2192ff7136f649c32e6df1db89
parentc793d13944b45d7a655ad230717cd5f335101920
x86/vmx: use a MEMF_no_refcount domheap page for APIC_DEFAULT_PHYS_BASE

vmx_alloc_vlapic_mapping() currently contains some very odd looking code
that allocates a MEMF_no_owner domheap page and then shares with the guest
as if it were a xenheap page. This then requires vmx_free_vlapic_mapping()
to call a special function in the mm code: free_shared_domheap_page().

By using a MEMF_no_refcount domheap page instead, the odd looking code in
vmx_alloc_vlapic_mapping() can simply use get_page_and_type() to set up a
writable mapping before insertion in the P2M and vmx_free_vlapic_mapping()
can simply release the page using put_page_alloc_ref() followed by
put_page_and_type(). This then allows free_shared_domheap_page() to be
purged.

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
xen/arch/x86/hvm/vmx/vmx.c
xen/arch/x86/mm.c
xen/include/asm-x86/mm.h